﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HQWeb.SysManage.UniualMateral
{
    public partial class TreeList : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            VerdictIsLogin();
            if (!IsPostBack)
            {
                InitTree();
            }
        }
        #region 树形类型树
        private void InitTree()
        {

            TreeNode node = new TreeNode();
            node.Text = "月份";
            node.Value = "";
            node.Target = "mainFrame";
            node.Expanded = true;
            node.SelectAction = TreeNodeSelectAction.Expand;
            node.NavigateUrl = "List.aspx?type=month&id=";
            TreeNode node1 = new TreeNode();
            node1.Text = "预算";
            node1.Value = "";
            node1.Target = "mainFrame";
            node1.Expanded = true;
            node1.SelectAction = TreeNodeSelectAction.Expand;
            node1.NavigateUrl = "List.aspx?type=price&id=";
            LeftTree.Nodes.Add(node);
            LeftTree.Nodes.Add(node1);
            AddReplies(node);
            AddPriceNode(node1);
        }
        #endregion

        #region 加载月份子节点
        private void AddReplies(TreeNode node)
        {
            try
            {
                string[] strArry = { "一月份", "二月份", "三月份", "四月份", "五月份", "六月份", "七月份", "八月份", "九月份", "十月份", "十一月份", "十二月份" };
                for (int i = 1; i < 13; i++)
                {
                    TreeNode replyNode = new TreeNode();
                    replyNode.Text = strArry[i-1];
                    replyNode.Value = i.ToString();
                    replyNode.NavigateUrl = "List.aspx?type=month&id=" + replyNode.Value;
                    replyNode.Target = "mainFrame";
                    replyNode.Expanded = false;
                    replyNode.SelectAction = TreeNodeSelectAction.Expand;
                    node.ChildNodes.Add(replyNode); 
                }
               
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        #endregion

        #region 加载预算子节点

        private void AddPriceNode(TreeNode node)
        {
            BLL.SysManage.T_PUB_DICTIONARY dictionyBll = new BLL.SysManage.T_PUB_DICTIONARY();
            List<Model.SysManage.T_PUB_DICTIONARY> list = dictionyBll.GetListArray(" PARENT_ID=6");
            foreach (Model.SysManage.T_PUB_DICTIONARY item in list)
            {
                   TreeNode replyNode = new TreeNode();
                    replyNode.Text = item.NAME;
                    replyNode.Value =item.ID.ToString();
                    replyNode.NavigateUrl = "List.aspx?type=price&id=" + replyNode.Value;
                    replyNode.Target = "mainFrame";
                    replyNode.Expanded = false;
                    replyNode.SelectAction = TreeNodeSelectAction.Expand;
                    node.ChildNodes.Add(replyNode); 
            }
        }

        #endregion
    }
}